﻿
namespace BusinessApplication.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using BusinessApplication.Web.Model;
    using BusinessApplication.Web.Models;


    // Implements application logic using the DatabaseEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public class TblProductsService : LinqToEntitiesDomainService<DatabaseEntities>
    {

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'tbl_products' query.
        public IQueryable<tbl_products> GetTbl_products()
        {
            return this.ObjectContext.tbl_products;
        }

    

        public void InsertTbl_products(tbl_products tbl_products)
        {
            if ((tbl_products.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(tbl_products, EntityState.Added);
            }
            else
            {
                this.ObjectContext.tbl_products.AddObject(tbl_products);
            }
        }

        public void UpdateTbl_products(tbl_products currenttbl_products)
        {
            this.ObjectContext.tbl_products.AttachAsModified(currenttbl_products, this.ChangeSet.GetOriginal(currenttbl_products));
        }

        public void DeleteTbl_products(tbl_products tbl_products)
        {
            if ((tbl_products.EntityState == EntityState.Detached))
            {
                this.ObjectContext.tbl_products.Attach(tbl_products);
            }
            this.ObjectContext.tbl_products.DeleteObject(tbl_products);
        }
    }
}


